package com.mapper;

import com.bean.ClazzBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ClazzMapperByAnnotation2 {

    @Select("select * from t_clazz")
    public List<ClazzBean> getAllClazz();

    @Select("select * from t_clazz where id=#{id}")
    @Results({@Result( id = true,column = "id",property = "id"),@Result(column = "cname",property = "cname")})
    public ClazzBean getClazzById(Integer id);

    @Insert("insert into t_clazz (cname) values (#{cname}) ")
    public int addClazz(ClazzBean clazzBean);
    @Delete("delete from  t_clazz where id=#{id}")
    public int delClazzById(int id);


    @Select("select * from t_clazz where id=#{id}")
    @Results({@Result(id = true,column = "id",property = "id"),
            @Result(column = "cname",property = "cname"),
            @Result(column = "id",property = "students",many = @Many(select = "com.mapper.StudentMapperByAnnotation.findStuForClazzId"))
    })
    public ClazzBean getClazzForStuById(Integer id);

}
